home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWIcon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  4.6 KB  |  165 lines  |  [TEXT/MPS ]

  1. #ifndef FWICON_H
  2. #define FWICON_H
  3.  
  4. //========================================================================================
  5. //
  6. //    File:                FWIcon.h
  7. //    Release Version:    $ 1.0d11 $
  8. //
  9. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #if FW_LIB_EXPORT_PRAGMAS
  14. #pragma lib_export on
  15. #endif
  16.  
  17. #ifndef FWGROBJ_H
  18. #include "FWGrObj.h"
  19. #endif
  20.  
  21. #ifndef FWGRDEF_H
  22. #include "FWGrDef.h"
  23. #endif
  24.  
  25. //========================================================================================
  26. //    Forward Declarations
  27. //========================================================================================
  28.  
  29. class FW_CLASS_ATTR FW_CResourceFile;
  30. class FW_CLASS_ATTR FW_CGraphicContext;
  31. class FW_CLASS_ATTR FW_CRect;
  32. class FW_CLASS_ATTR FW_CPoint;
  33.  
  34. class FW_CLASS_ATTR FW_PIcon;
  35. class FW_CLASS_ATTR FW_CIconRep;
  36.  
  37. //========================================================================================
  38. //    class FW_PIcon
  39. //========================================================================================
  40.  
  41. class FW_CLASS_ATTR FW_PIcon : public FW_CGraphicCountedPtr
  42. {
  43. public:
  44.     FW_DECLARE_CLASS
  45.     
  46.                         FW_PIcon();
  47.                         FW_PIcon(FW_CReadableStream& archive);
  48.                         FW_PIcon(FW_PlatformIcon platformIcon);
  49.                         FW_PIcon(FW_CResourceFile& resourceFile,
  50.                                  FW_ResourceId resId,
  51.                                  short size);
  52.     virtual                ~FW_PIcon();
  53.  
  54.                         FW_PIcon(const FW_PIcon& other);
  55.     FW_PIcon&            operator=(const FW_PIcon& other);
  56.  
  57.     FW_CIconRep*        operator->();
  58.     const FW_CIconRep*    operator->() const;
  59. };
  60.  
  61. //========================================================================================
  62. //    class FW_CIconRep
  63. //========================================================================================
  64.  
  65. class FW_CLASS_ATTR FW_CIconRep : public FW_CGraphicCountedPtrRep
  66. {
  67. public:
  68.     FW_DECLARE_CLASS
  69.     
  70.     friend FW_PIcon;
  71.  
  72. //----------------------------------------------------------------------------------------
  73. //    Constructors/Destructors
  74. //
  75. protected:
  76.                             FW_CIconRep(FW_PlatformIcon platformIcon);
  77.                             FW_CIconRep(FW_CResourceFile& resourceFile,
  78.                                         FW_ResourceId resId,
  79.                                         short size);
  80.  
  81.                             FW_CIconRep(FW_CReadableStream& archive);
  82.  
  83.     virtual                 ~FW_CIconRep();
  84.  
  85. //----------------------------------------------------------------------------------------
  86. //    Inherited API
  87. //
  88. public:
  89.     virtual void            Flatten(FW_CWritableStream& archive) const;
  90.     virtual FW_Boolean        IsEqual(const FW_CGraphicCountedPtrRep* other) const;
  91.  
  92. //----------------------------------------------------------------------------------------
  93. //    New API
  94. //
  95. public:
  96.     // ----- Copying -----
  97.     FW_PIcon            Copy() const;
  98.     
  99.     // ----- Get, Set, Adopt and Orphan
  100.     FW_PlatformIcon        GetPlatformIcon() const;
  101.     FW_PlatformIcon        OrphanPlatformIcon();
  102.     
  103.     void                SetPlatformIcon(FW_PlatformIcon newIcon);
  104.     void                AdoptPlatformIcon(FW_PlatformIcon newIcon);
  105.     
  106.     // ----- Archiving -----
  107.     static void*        Read(FW_CReadableStream& archive);
  108.  
  109.     // ---- Geometry -----
  110.     void                GetIconSize(FW_CPoint& size) const;                            // Size in pixels
  111.     void                GetIconSize(FW_CGraphicContext& gc, FW_CPoint& size) const;    // Size in gc units
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    Implementation
  115. //
  116. protected:
  117.     void                    DisposePlatformIcon();
  118.     
  119.     static FW_PlatformIcon    CopyPlatformIcon(FW_PlatformIcon icon);
  120.     static short            GetPlatformIconSize(FW_PlatformIcon icon);
  121.  
  122. private:
  123.     FW_Boolean            fOwnIcon;
  124.     FW_PlatformIcon        fPlatformIcon;
  125.     short                fIconSize;
  126. };
  127.  
  128. //========================================================================================
  129. //    Inlines
  130. //========================================================================================
  131.  
  132. //----------------------------------------------------------------------------------------
  133. //    FW_PIcon::operator->
  134. //----------------------------------------------------------------------------------------
  135.  
  136. inline FW_CIconRep* FW_PIcon::operator->()
  137. {
  138.     return (FW_CIconRep*) GetRep();
  139. }
  140.  
  141. //----------------------------------------------------------------------------------------
  142. //    FW_PIcon::operator->
  143. //----------------------------------------------------------------------------------------
  144.  
  145. inline const FW_CIconRep* FW_PIcon::operator->() const
  146. {
  147.     return (const FW_CIconRep*) GetRep();
  148. }
  149.  
  150. //----------------------------------------------------------------------------------------
  151. //    FW_CIconRep::GetPlatformIcon
  152. //----------------------------------------------------------------------------------------
  153.  
  154. inline FW_PlatformIcon FW_CIconRep::GetPlatformIcon() const
  155. {
  156.     return fPlatformIcon;
  157. }
  158.  
  159. #if FW_LIB_EXPORT_PRAGMAS
  160. #pragma lib_export off
  161. #endif
  162.  
  163. #endif // FWICON_H
  164.  
  165.